<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8"/>
    <title>文库搜索</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta
            name="viewport"
            content="width=device-width, initial-scale=1, maximum-scale=1"
    />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
    <link rel="stylesheet" href="../../../statics/sdk/sdk.css"/>
    <link rel="stylesheet" href="../../../statics/sdk/helper.css"/>
    <!-- 从 1.1.0 开始 sdk.css 将不支持 IE 11，如果要支持 IE11 请引用这个 css，并把前面那个删了 -->
    <!-- <link rel="stylesheet" href="sdk-ie11.css" /> -->
    <!-- 不过 amis 开发团队几乎没测试过 IE 11 下的效果，所以可能有细节功能用不了，如果发现请报 issue -->
    <style>
        html,
        body,
        .app-wrapper {
            position: relative;
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }
    </style>
</head>
<body>
<div id="root" class="app-wrapper"></div>
<script src="../../../statics/sdk/sdk.js"></script>
<script type="text/javascript">
    (function () {
        let amis = amisRequire('amis/embed');
        // 通过替换下面这个配置来生成不同页面
        let amisJSON =
            {
                "type": "page",
                "toolbar": [
                    {
                        "type": "form",
                        "title": "查询条件",
                        "target": "article-crud, file-crud",
                        "body": [
                            {
                                "type": "input-text",
                                "name": "full_text",
                                "label": "全文搜索",
                                "mode":"inline",
                                "size": "lg",
                            },
                            {
                                "type": "button",
                                "actionType": "clear-and-submit",
                                "mode":"inline",
                                "label": "重置"
                            },
                            {
                                "type": "submit",
                                "mode":"inline",
                                "label": "搜索",
                                "level": "primary"
                            }
                        ]
                    }
                ],
                "body": [
                    {
                        "type": "tabs",
                        "mode": "chrome",
                        "tabs": [
                            {
                                "title": "文章",
                                "body": [
                                    {
                                        "type": "crud",
                                        "name": "article-crud",
                                        "api": "../../kbms/kbmsarticlemain/listByFullText",
                                        "headerToolbar": [
                                            {
                                                "type": "statistics",
                                                "align": "right"
                                            }
                                        ],
                                        "itemActions": [
                                            {
                                                "label": "详情",
                                                "type": "button",
                                                "actionType": "dialog",
                                                "level": "link",
                                                "dialog": {
                                                    "title": "详情评论",
                                                    "closeOnEsc": true,
                                                    "resizable": true,
                                                    "size": "lg",
                                                    "actions": [
                                                        {
                                                            "type": "button",
                                                            "actionType": "reload",
                                                            "label": "关闭",
                                                            "close": true,
                                                            "target": "article-crud"
                                                        }
                                                    ],
                                                    "body": {
                                                        "type": "page",
                                                        "initApi": "../../sys/user/infoByAmis",
                                                        "body": [
                                                            {
                                                                "type": "static",
                                                                "tpl": "$title",
                                                                "className": "text-lg font-bold"
                                                            },
                                                            {
                                                                "type": "static",
                                                                "tpl": "$user_name &nbsp&nbsp&nbsp 发布时间: $o_create_time &nbsp&nbsp&nbsp 浏览量: $browse_num",
                                                                "className": "font-thin text-sm text-muted"
                                                            },
                                                            {
                                                                "type": "input-rich-text",
                                                                "name": "article_content",
                                                                "mode": "normal",
                                                                "options": {
                                                                    "menubar": false,
                                                                    "readonly": true,
                                                                    "toolbar": "",
                                                                    "plugins": "autoresize",
                                                                    "height": "800"
                                                                }
                                                            },
                                                            {
                                                                "type": "crud",
                                                                "name": "comment-crud",
                                                                "api": "../../kbms/kbmsarticlecomment/list?id=$article_id&page=$page&perPage=$perPage",
                                                                "perPageAvailable": [
                                                                    3
                                                                ],
                                                                "messages": {},
                                                                "listItem": {
                                                                    "body": [
                                                                        {
                                                                            "type": "hbox",
                                                                            "columns": [
                                                                                {
                                                                                    "name": "comment_name"
                                                                                },
                                                                                {
                                                                                    "name": "comment_time"
                                                                                }
                                                                            ]
                                                                        },
                                                                        {
                                                                            "name": "comment_content"
                                                                        }
                                                                    ]
                                                                },
                                                                "mode": "list",
                                                                "perPage": 3,
                                                                "alwaysShowPagination": true,
                                                                "headerToolbar": [],
                                                                "footerToolbar": [
                                                                    {
                                                                        "type": "statistics",
                                                                        "tpl": "内容"
                                                                    },
                                                                    {
                                                                        "label": "查看全部",
                                                                        "type": "button",
                                                                        "level": "link",
                                                                        "actionType": "link",
                                                                        "link": ""
                                                                    },
                                                                ]
                                                            },
                                                            {
                                                                "type": "input-text",
                                                                "label": "登录用户",
                                                                "name": "username",
                                                                "mode": "inline",
                                                                "disabled": true,
                                                                "size": "sm"
                                                            },
                                                            {
                                                                "type": "form",
                                                                "title": "评论内容",
                                                                "resetAfterSubmit": true,
                                                                "initApi": "../../kbms/kbmsarticlemain/addBrowseNumByArticleId/$article_id",
                                                                "actionType": "ajax",
                                                                "api": "../../kbms/kbmsarticlecomment/save",
                                                                "reload": "comment-crud",
                                                                "body": [
                                                                    {
                                                                        "type": "textarea",
                                                                        "name": "new_comment_content",
                                                                    },
                                                                    {
                                                                        "type": "hidden",
                                                                        "name": "user_id",
                                                                    },
                                                                    {
                                                                        "type": "hidden",
                                                                        "name": "article_id",
                                                                    }
                                                                ]
                                                            }
                                                        ]
                                                    }
                                                }
                                            }
                                        ],
                                        "features": [
                                            "view"
                                        ],
                                        "perPageAvailable": [
                                            5,10,20
                                        ],
                                        "messages": {},
                                        "footerToolbar": [
                                            "switch-per-page",
                                            "pagination"
                                        ],
                                        "alwaysShowPagination": true,
                                        "mode": "table",
                                        "columns": [
                                            {
                                                "name": "title",
                                                "label": "标题",
                                                "type": "text"
                                            },
                                            {
                                                "type": "text",
                                                "label": "作者",
                                                "name": "user_name"
                                            },
                                            {
                                                "type": "datetime",
                                                "label": "发布时间",
                                                "name": "create_time"
                                            },
                                            {
                                                "type": "text",
                                                "label": "浏览数",
                                                "name": "browse_num"
                                            },
                                            {
                                                "type": "text",
                                                "label": "最新评论",
                                                "name": "comment_content"
                                            }
                                        ],
                                        "checkOnItemClick": true,
                                        "hideQuickSaveBtn": false,
                                        "affixHeader": false,
                                        "showHeader": true,
                                        "showFooter": true,
                                        "footable": true,
                                        "columnsTogglable": true,
                                        "syncLocation": false,
                                        "keepItemSelectionOnPageChange": false,
                                        "toggled": true,
                                        "initFetch": ""
                                    }
                                ]
                            },
                            {
                                "title": "文档",
                                "body": {
                                    "type": "crud",
                                    "name": "file-crud",
                                    "api": "../../kbms/kbmsfilemain/listByFullText",
                                    "headerToolbar": [
                                        {
                                            "type": "statistics",
                                            "align": "right"
                                        }
                                    ],
                                    "itemActions": [
                                        {
                                            "label": "下载",
                                            "type": "button",
                                            "level": "link",
                                            "actionType": "link",
                                            "link": "../../sys/file/download/$origin_name/$id",
                                            "reload": "file-crud"
                                        },
                                        {
                                            "label": "评论",
                                            "type": "button",
                                            "actionType": "drawer",
                                            "level": "link",
                                            "drawer": {
                                                "title": "文档评论",
                                                "closeOnEsc": true,
                                                "resizable": true,
                                                "actions": [
                                                    {
                                                        "type": "button",
                                                        "actionType": "reload",
                                                        "label": "关闭",
                                                        "close": true,
                                                        "target": "file-crud"
                                                    }
                                                ],
                                                "body": {
                                                    "type": "form",
                                                    "initApi" : "../../sys/user/infoByAmis",
                                                    "body": [
                                                        {
                                                            "label": "文件大小",
                                                            "type": "input-text",
                                                            "name": "file_size",
                                                            "size": "sm",
                                                            "mode": "inline",
                                                            "disabled": true,
                                                            "addOn": {
                                                                "type": "text",
                                                                "label": "B"
                                                            }
                                                        },
                                                        {
                                                            "label": "上传用户",
                                                            "type": "input-text",
                                                            "name": "user_name",
                                                            "size": "sm",
                                                            "disabled": true,
                                                            "mode": "inline"
                                                        },
                                                        {
                                                            "label": "上传时间",
                                                            "type": "input-text",
                                                            "name": "o_create_time",
                                                            "size": "sm",
                                                            "disabled": true,
                                                            "mode": "inline"
                                                        },
                                                        {
                                                            "label": "下载数量",
                                                            "type": "input-text",
                                                            "name": "download_num",
                                                            "size": "xs",
                                                            "disabled": true,
                                                            "mode": "inline"
                                                        },
                                                        {
                                                            "label": "下载文件",
                                                            "type": "button",
                                                            "level": "link",
                                                            "actionType": "link",
                                                            "link": "../../sys/file/download/$origin_name/$id"
                                                        },
                                                        {
                                                            "type": "crud",
                                                            "name": "comment-crud",
                                                            "api": "../../kbms/kbmsfilecomment/list?id=$id&page=$page&perPage=$perPage",
                                                            "perPageAvailable": [
                                                                3
                                                            ],
                                                            "messages": {},
                                                            "listItem": {
                                                                "body": [
                                                                    {
                                                                        "type": "hbox",
                                                                        "columns": [
                                                                            {
                                                                                "name": "comment_name"
                                                                            },
                                                                            {
                                                                                "name": "comment_time"
                                                                            }
                                                                        ]
                                                                    },
                                                                    {
                                                                        "name": "comment_content"
                                                                    }
                                                                ]
                                                            },
                                                            "mode": "list",
                                                            "perPage": 3,
                                                            "alwaysShowPagination": true,
                                                            "headerToolbar": [],
                                                            "footerToolbar": [
                                                                {
                                                                    "type": "statistics",
                                                                    "tpl": "内容"
                                                                },
                                                                {
                                                                    "label": "查看全部",
                                                                    "type": "button",
                                                                    "level": "link",
                                                                    "actionType": "link",
                                                                    "link": ""
                                                                },
                                                            ]
                                                        },
                                                        {
                                                            "type": "input-text",
                                                            "label": "登录用户",
                                                            "name": "username",
                                                            "mode": "inline",
                                                            "disabled": true,
                                                            "size": "sm"
                                                        },
                                                        {
                                                            "type": "form",
                                                            "title": "评论内容",
                                                            "resetAfterSubmit": true,
                                                            "actionType": "ajax",
                                                            "api": "../../kbms/kbmsfilecomment/save",
                                                            "reload": "comment-crud",
                                                            "body": [
                                                                {
                                                                    "type": "textarea",
                                                                    "name": "comment_content",
                                                                },
                                                                {
                                                                    "type": "hidden",
                                                                    "name": "user_id",
                                                                },
                                                                {
                                                                    "type": "hidden",
                                                                    "name": "id",
                                                                }
                                                            ]
                                                        }
                                                    ]
                                                }
                                            }
                                        }
                                    ],
                                    "features": [
                                        "update",
                                        "view"
                                    ],
                                    "perPageAvailable": [
                                        5,10,20
                                    ],
                                    "messages": {},
                                    "footerToolbar": [
                                        "switch-per-page",
                                        "pagination"
                                    ],
                                    "alwaysShowPagination": true,
                                    "mode": "table",
                                    "columns": [
                                        {
                                            "name": "file_name",
                                            "label": "文件名称",
                                            "type": "text"
                                        },
                                        {
                                            "name": "origin_name",
                                            "label": "源文件名称",
                                            "type": "text"
                                        },
                                        {
                                            "type": "text",
                                            "label": "上传用户",
                                            "name": "user_name"
                                        },
                                        {
                                            "type": "datetime",
                                            "label": "上传时间",
                                            "name": "create_time"
                                        },
                                        {
                                            "type": "text",
                                            "label": "下载数",
                                            "name": "download_num"
                                        },
                                        {
                                            "type": "text",
                                            "label": "最新评论",
                                            "name": "content"
                                        }
                                    ],
                                    "checkOnItemClick": true,
                                    "hideQuickSaveBtn": false,
                                    "affixHeader": false,
                                    "showHeader": true,
                                    "showFooter": true,
                                    "footable": true,
                                    "columnsTogglable": true,
                                    "syncLocation": false,
                                    "keepItemSelectionOnPageChange": false,
                                    "toggled": true,
                                    "initFetch": ""
                                }
                            }
                        ]
                    }
                ]
            }
        let amisScoped = amis.embed('#root', amisJSON);
    })();
</script>
</body>
</html>